﻿using System;
using System.ServiceProcess;
using System.Windows.Forms;

namespace Hongwei.AS3PolicyServer.Server
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            if (0 == args.Length)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Forms.MainForm());
            }
            else
            {
                switch (args[0])
                {
                    case "-i":
                        if (Actions.Service.Install())
                        {
                            Console.WriteLine("服务安装成功。");
                        }
                        else
                        {
                            Console.WriteLine("服务安装失败。");
                        }
                        break;
                    case "-u":
                        if (Actions.Service.Uninstall())
                        {
                            Console.WriteLine("服务卸载成功。");
                        }
                        else
                        {
                            Console.WriteLine("服务卸载失败。");
                        }
                        break;
                    case "-s":
                        ServiceBase[] ServicesToRun;
                        ServicesToRun = new ServiceBase[] { new Services.PolicyService() };
                        ServiceBase.Run(ServicesToRun);
                        break;
                }
            }
        }
    }
}
